<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
var firstUniqChar = function(s) {
    for( var i = 0; i<s.length ; i++ ){
        var one = s[i]
        var count = 0
        for( var j = 0; j<s.length ; j++ ){
            if( s[j] === one ){
                count++
            }
        }
        if( count==1 ){
            return i
        }
    }
    return -1
};
s = "dddccdbba"
console.log(firstUniqChar(s))
// 暴力解法超时
    </script>
</body>
</html>